Skip to content

fix(formula): label() over a multi-select reads each selected option's label, joined - #34443

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34339-formula-label-multi-select
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34339-formula-label-multi-select

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #34339

Clause-②: no
Metadata-protocol: semantic
Skills-docs: follow-up #34444 (skills/objectstack-formula/SKILL.md, the label(record.f) row; the multi-select join is taught in content/docs/data-modeling/formulas.mdx in this PR)

维护者速读

  • 改了什么:公式 label(record.X) 作用在多选字段(multiple: true 的 select)上,不再出错读成 null,而是按读者语言输出每个已选项的标签,按记录里存储的顺序,用 , 连接;空选择仍读 '',单选不变。
  • 为什么改:下游 CRM 报价行用多选字段 + label() 拼一句「无法估算毛利的原因」,在 18.5.0 上每条记录都读成 null,而 os validate / os lint --strict 都放行。
  • 风险与回滚:风险低。只有原先读成 null 的公式变成有文字;单选、空值、未知值的读法不变。和邮件模板 option 占位符走同一个拼接函数,两边不会再分叉。回滚即撤销本 PR。
  • 先看:packages/formula/src/stdlib.ts 的 labelEachOption 与 optionLabelOf / oneOptionLabel;packages/formula/src/template-engine.ts 的 option 格式化器那一行;packages/objectql/src/engine-formula-option-label.test.ts 末尾新增的 describe。
  • 两分钟验证:pnpm --filter @objectstack/formula exec vitest run src/option-label.test.ts,预期 18 个用例全绿(在 main 上其中 7 个红)。
  • 需要你做的:无,席位落地。

What changes

label(record.FIELD) over a multiple: true select used to throw (renders ONE option value, and FIELD holds a list of values), so the formula field read null on every non-empty selection. It now reads:

Value Reads
['no_sales_price', 'no_customer'] 无销售价, 无客户 (zh-CN) / No sales price, No customer (en-US)
['no_freight_region'] that one label
[], null '' (unchanged; measured below)
a listed value no option declares as stored, as the single-value path reads an unknown value
a list holding an object runtime fault, as an object value faults today
  • One rule, one helper. labelEachOption (packages/formula/src/stdlib.ts, package-internal) maps each listed value through the caller's single-value lookup and joins with , . The mail template's option hole (template-engine.ts, OPTION_ARGUMENT_RULE) now calls the same helper instead of its own map(...).join(', '), so the two cannot drift. A unit test asserts label() and formatValue('option', …) print the same string for the same list.
  • Order: stored order. Measured: ['no_freight_region', 'no_sales_price'] reads No freight region, No sales price, although the options declare no_sales_price first. That is the order the template engine already used. This is the claim's choice (claim 6923097287, Shape: "by the same rule the mail-template option hole already uses"), and it differs from the card's words: ask 1 says "joined with , in option order" while naming the mail-template option hole (OPTION_ARGUMENT_RULE) as precedent, and that hole measures STORED order. So a reader of the downstream CRM quote line gets the labels in the order the values were stored, not the order the options are declared.
  • No labels() sibling, and no author-time refusal (the card's ask 2): the card asks for it only "Until (1) ships", and ask 1 ships here; claim 6923097287 (Shape) records that choice. Ruling 6919059607 is the claim permission (batch 1), not a ruling on order or on ask 2.
  • The objectql seam needed no change. formula-option-labels.ts builds the label map from every served field that declares options, whatever multiple says, with the translation bundle laid over it. The real-engine pin below reads translated multi-select labels through it unchanged.
  • Docs: content/docs/data-modeling/formulas.mdx said "A multi-value select is refused." It now teaches the join, the order and the empty reading.

Tests

  • packages/formula/src/option-label.test.ts: a new describe for the multi-select (zh-CN and en-US join, one element, stored order, empty list and null, unknown value, composition, a field without options, an object inside the list, and agreement with the mail option hole). The old "refuses a list value" assertion is removed. An object value is still refused, in its own case.
  • packages/objectql/src/engine-formula-option-label.test.ts: a new top-level describe on the real ObjectQL engine (stub driver, i18n service with a zh-CN bundle) reads label(record.gaps) over a multi-select in zh-CN and en-US, beside a single-select CONTROL on the same record, plus the one-element and empty cases.
  • packages/qa/dogfood/test/formula-option-label-locale.dogfood.test.ts: the fixture gains a multi-select and its formula. One new case reads it through REST (POST / GET /data/:object/:id with Accept-Language) in zh-CN and en-US, with the existing single-select name as the CONTROL, plus the one-element, empty-list and unset cases.

Acceptance notes

  • main is red on check:platform-checklist (approvals.approver-resolution-matrix VARIANTS STALE). That red is main's, not this diff's; the seat has a stopgap PR. Lint & Repo Gates will show it on this PR.
  • A CEL read of a key the record does not carry (record.gaps on {}) faults with No such key before label() runs. This is the same for a single select and is not changed here. The engine hands formulas every declared field, so a stored record does not hit it.

Verification

All readings below come from runs under scripts/pm/os-verify-lock.sh, on a shared box.

  • Final head 4a1ed6a82f: the dogfood file alone, after turbo run build --filter='@objectstack/dogfood^...' (70 tasks, exit 0): pnpm --filter @objectstack/dogfood exec vitest run --maxWorkers=1 test/formula-option-label-locale.dogfood.test.ts gives Test Files 1 passed (1), Tests 6 passed (6) (5 existing + the new multi-select case). Lock VERDICT command-exit 0. Its red on main was not run; the objectql pin carries the red-on-main reading.
Red on main (tests at c0547aa, formula source at the merge base)
  • pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/option-label.test.ts: Tests 7 failed | 11 passed (18). Each of the seven multi-select cases answered { ok: false, … }.
  • pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-formula-option-label.test.ts: Tests 2 failed | 10 passed (12), AssertionError: expected null to be '无销售价, 无客户'. The engine logged the card's own line: formula field 'gaps_note' on 'ol_quote_line' could not be evaluated, so it reads null … label(record.gaps) renders ONE option value, and gaps holds a list of values on this record.
  • The empty-selection case was already green on main at the engine level: the engine reads '' for [] and for null there, and still does.
Green, and the ablation (one locked run at 6fa079a; formula src unchanged since)
  • pnpm --filter @objectstack/formula build: exit 0. node scripts/ablation-dist-preflight.mjs @objectstack/formula 'oneOptionLabel(field, item, options, true)': marker present in dist/index.js and dist/index.mjs.
  • objectql file: Tests 12 passed (12).
  • pnpm --filter @objectstack/formula typecheck: exit 0.
  • Ablation: node scripts/ablation-replace.mjs --file packages/formula/src/stdlib.ts --anchor ' if (Array.isArray(value)) return labelEachOption(…);' --delete -- …. Anchor count went from 1 to 0, blob af2083df5155 to a999c7ce79c1. Formula rebuilt, --absent preflight: marker absent from all 6 built files. Then objectql file Tests 2 failed | 10 passed (12) and formula file Tests 7 failed | 11 passed (18). Restore: blob == HEAD (af2083df5155) and git diff HEAD is empty. Rebuilt, marker present again, objectql file Tests 12 passed (12).
  • At the final head 4a1ed6a, which only drops one assertion from option-label.test.ts: pnpm --filter @objectstack/formula test gives Test Files 67 passed (67), Tests 1770 passed (1770).
Derived gates

At the final head 4a1ed6a82f: node scripts/pm/dispatch-gates.mjs --commands derived 94 commands, and all 94 were run locally, each exit code captured before any pipe: 94 exit 0. node scripts/pm/dispatch-gates.mjs --ran gives: 94 derived famil(ies) accounted for — 94 run, 0 NOT-MEASURED (a DERIVED zero — all 94 recorded an exit code and none of them is 3). CI's Lint & Repo Gates runs the full farm.

  • Dogfood battery: not owed (no ! in the title, no (narrowing) arm).

Generated by Claude Code

…els per reader locale

Red on main: label(record.<multi-select>) faults and the formula reads null.

Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-authored-by: Claude <noreply@anthropic.com>
…joined

label(record.<field>) over a multiple: true select faulted on every non-empty
selection, so the formula field read null. It now reads the label of each
selected value in the reader's locale, in stored order, joined with ', ' —
through labelEachOption, the one helper the mail template's option hole
prints a multi-select by too.

Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-authored-by: Claude <noreply@anthropic.com>
…and en-US; changeset

Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-authored-by: Claude <noreply@anthropic.com>
… before label() runs

Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

4 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a121e29c280aefb60fdbd48f3f765c5dc8902884 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4b1aba9f9938d7b82c9994000e88f16305fc3447 — the merge of head 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be into base a121e29c280aefb60fdbd48f3f765c5dc8902884, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4b1aba9f9938d7b82c9994000e88f16305fc3447 && git checkout 4b1aba9f9938d7b82c9994000e88f16305fc3447
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a121e29c280aefb60fdbd48f3f765c5dc8902884 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be && git checkout -B drift-repro a121e29c280aefb60fdbd48f3f765c5dc8902884 && git merge --no-ff 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be

node scripts/docs-audit/affected-docs.mjs --json a121e29c280aefb60fdbd48f3f765c5dc8902884

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac

Final head for review · PR #34443 · 2026-11-16T18:20Z

Head-sha: 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be (dev report 6925075642 on #34339). Claim 6923097287; Ruling-ref 6919059607 (batch 1).
Shape (claim): label(record.f) over a multiple: true select reads each selected value's label in the reader's locale, joined , in STORED order. It uses one package-internal helper (labelEachOption, packages/formula/src/stdlib.ts), which the mail-template option hole now calls too, so the join has one spelling. An empty list or null reads '', as before. A listed value that no option declares reads as stored, the same as the single-value path. An object inside the list still faults. There is no labels() sibling and no author-time refusal (ask 2). The objectql option-label seam needed no change. content/docs/data-modeling/formulas.mdx said a multi-value select is refused; it now teaches the join.
Proof: red on main (formula 7 failed; objectql engine pin 2 failed with the card's own log line). Green at the head: formula 1770/1770; objectql pin 12/12 (zh-CN + en-US beside the single-select CONTROL); dogfood REST file 6/6. Ablation of the list branch: 7 + 2 red, restored green. 94/94 derived gates exit 0, --ran reconciled.
Declarations: Clause-②: no, Metadata-protocol: semantic (formula minor). There is no packages/spec/src/** path, so no L2 is owed under landing-operations. Skills-docs: follow-up #34444 (filed by the area). PR body: trailer and Skills-docs line patched.
Checks at this head: running at announce. A Lint & Repo Gates red from check:platform-checklist would be main's (#34435).
Owed for landing: L1 (L1-b); CI green.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn

席位核对 · PR #34443 · L1-b · 2026-11-16T18:23Z

Head-sha: 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be(merge-base 9e6fee1,7 个文件 +261/−17)

结论:REWORK,一项,只改正文。代码、测试、changeset、docs 按读到的都可以接受。

已核对、无问题

  • stdlib.ts:
    • optionLabelOf 遇到数组走 labelEachOption,逐项调 oneOptionLabel(…, listed=true);单值路径不变。
    • 空数组和 null 读 '',未声明的值按原样读,列表里有对象仍 runtime fault。
    • labelEachOption 只在包内,没有从 index.ts 再导出。
  • template-engine.ts 的 option 洞改调同一个 helper,行为不变。⭐ 用例断言 label() 与 formatValue('option', …) 对同一列表输出同一字符串。
  • changeset 是 minor,声明 Metadata-protocol: semantic,与 check-changeset-no-major 的规则一致("semantic … takes minor");Clause-② 为 no(原来读 null,现在读文字,没有从拒绝变成放行)。
  • docs:formulas.mdx 删掉了不实的 "A multi-value select is refused",换成拼接、顺序、空值三条,与代码一致。
  • Skills:skills/objectstack-formula/SKILL.md:215 的 label(record.f) 行没有教错的句子,补充教学由 skills/objectstack-formula: teach that label() over a multi-select reads each selected label, joined #34444(open)承接。
  • 测试:formula、objectql 真引擎、dogfood REST 三层都有 zh-CN / en-US 与单选 CONTROL。正文写明 main 上红 7/18 与 2/12,消融得到同样的红数,恢复后转绿。
  • 遗留 "CEL 读不存在的键先 fault" 给了可核查的无缺陷理由:单选同样如此,而且引擎把每个声明字段都交给公式。
  • Dogfood battery 不欠(没有 !,没有 narrowing)。

REWORK

  • R1 · 正文把两处取舍记在了一条没有裁定它们的 ruling 名下。 Ruling 6919059607 只是认领许可("分两批点名放行,不改级别",batch 1 第 2 张),没有裁定顺序,也没有裁定 ask 2。正文有两句这样写:

    • "The card's wording said "option order"; the ruling chose the existing rule."
    • "No labels() sibling, and no author-time refusal (the card's ask 2), per the ruling (ruling-ref 6919059607)"

    请改成它们的真实出处:

    • 顺序:卡片 ask 1 写的是 "option order",同时指向 mail 模板 option 洞(OPTION_ARGUMENT_RULE)作为先例,而那个洞实测用的是存储顺序。认领 6923097287 的 Shape 选了"与该洞同一条规则"。请写明这是认领的取舍、与卡片原话不同,并附上测得的例子(正文已有)。下游的 CRM 报价行就是按卡片原话来的,"存储顺序"这一点要写清楚。
    • ask 2:卡片自己写着 "Until (1) ships",ask 1 落地后 ask 2 自然不再需要。认领 6923097287 第 18–19 行已经这么写,引它即可。

备注(不阻塞)

  • N1:旧用例删掉了对 fault 文字 renders ONE option value 的断言;新的 fault 句子("… holds a list with a non-option entry …" / "… an object …")现在没有任何测试钉住,只断言了 kind: 'runtime'。这句话会写进引擎日志,建议在"列表含对象"的用例里钉一个子串。
  • L1 未实测:
    • 列表里有 null 元素(例如 ['no_customer', null])时的读法:按代码会读成 'No customer, ',我没有跑。
    • 本 head 的 CI:25 success、12 skipped、32 in progress,无 failure,但尚未跑完。

修完后我只读 delta。正文没有 spec 路径,所以不欠 L2。落地前须本 head CI 全绿,按席位的落地路线走。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn

席位核对 · PR #34443 · L1-b · delta · 2026-11-16T18:24Z

Head-sha: 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be(head 未动,只读了正文的改动)

结论:delta ACCEPT。 R1 已关闭。

  • 存储顺序现在记在认领 6923097287 的 Shape 名下。正文写明了与卡片 "option order" 的差异和原因:卡片引用的 mail option 洞实测就是存储顺序。正文也写明了下游 CRM 报价行的读者会看到什么。
  • ask 2 现在引的是卡片自己的 "Until (1) ships" 和认领。正文也明说 ruling 6919059607 只是 batch 1 的认领许可。
  • N1(钉住 fault 句子)不阻塞。线程选择不动 head,接受。

L1 未实测: 本 head 的 CI 现为 28 success、14 skipped、31 in progress,无 failure,尚未跑完。

落地条款:须本 head CI 全绿,按席位的落地路线走。本 PR 不触及 spec 路径,不欠 L2。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac

Landing · PR #34443 · 2026-11-16T18:45Z

Probe Reading
Head 4a1ed6a82f02f6dbf0763d66c2a102ee4f8aa0be (announce 6925148135, dev report 6925075642 on #34339)
L1 REWORK 6925198529 (body only), then delta ACCEPT 6925238147 (L1-b) at this head; N1 (pin the new fault sentence) is non-blocking and not taken, so the head does not move
L2 not owed: Clause-②: no, no packages/spec/src/** path in the diff
check-governed-merges --pr 34443 NOT governed · 278 lines ≤ 3000
Checks at head 58 success, 12 skipped, none red, none running; mergeable clean
K (first-parent commits since PRBASE a121e29c, the Affected-set diff base of this head's Test Core run) 0 < 15
Battery not owed: no !, no narrowing arm
Skills-docs follow-up #34444

State change: ready for review + auto-merge (merge queue). On MERGED, Fixes #34339 closes the card; the area removes pm:dispatched and lease:o1-C in the close stroke.


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 18:45
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit d4e4dfb Nov 16, 2026
77 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34339-formula-label-multi-select branch November 16, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants